<?php 
session_start();
if (!isset($_SESSION['admin'])) 
{ 
require "includes/message_connexion.php";
}
else {
	if ($_SESSION['admin']<>'admin') 
	{
		require "includes/message_acces.php";
		}
	else {

		include('includes/config_bdd.php');
		try 
		{
			$bdd = new PDO('mysql:host='.$db_server.';dbname='.$db_name.'', ''.$db_username.'', ''.$db_password.'' );
		}
		catch (Exception $e)
		{
			Echo "erreur sur la connexion à la base de données ".$e->getMessage();
			die ('Erreur : '.$e->getMessage());
		} 
		$requete = $bdd->prepare("SET NAMES 'utf8'");
		$requete->execute();

		
		//suppresion 
		if(Isset($_GET['supp'])) {
		$requete = $bdd->prepare("delete from fiche_client where code_client_hto ='".$_GET['supp']."' ");
		$requete->execute();
		$requete = $bdd->prepare("delete from detail_client where code_client_hto ='".$_GET['supp']."' ");
		$requete->execute();
		}
		//chargement client 
		$requete = $bdd->prepare("SELECT * FROM fiche_client");
		$requete->execute();
		$tableauclientall=$requete->fetchall(PDO::FETCH_ASSOC);
		$requete->closeCursor();
		
		
		
		
		 
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Espace Client</title>
</head>

<body>

<?php
	if (isset($_GET['success'])){
?>
<script>window.alert('Création client Ok');</script>
<?php
	}
?>
	
<div class="container">
	
	<div class="row">
		<div class="span12">
			<img src="images/header.jpg" width="100%"/>
			<?php require "includes/menu-admin.php";?>
			
			<a href="./logout.php" class="pull-right"><i class="icon-user"></i> déconnexion </a>
		</div>
	</div>
    <div class="row">
    <div class="span12">
	
	  <fieldset>
		<legend>Recherche Client</legend>
<form  method=post action=detail-client.php><br /></br>
 <input name=client id=client type="text" value=" N° compte client " /> 
	    <input name="nom" id="client1" type="text" value=" Nom " />
	    <input name="client3" id="client3" type="text" value=" N° ligne mobile " /> 
	    <input name="client4" id="client4" type="text" value=" N° carte sim " />
        <button type="submit" class="btn btn-primary" name="nom">Rechercher Client</button>
	    </form>
      </fieldset>
      </div>
      </div>
          <div class="span12">
      <a href=creation-compte-mobile.php class="btn btn btn-primary" > Création compte Mobile</a>
  
      </div>
    <div class="row">
    <div class="span12">
    <fieldset>
    <legend>Liste Client</legend>
		<table class="table table-striped">
				 
					<tr>
					 <?php foreach ($tableauclientall as $ligneclient=>$client)
				{?>
				<tr><td>
				<?php echo $client['code_client_hto']; ?> 
				</td> 
                <td> <?php echo $client['nom']." ".$client['prenom'] ; ?></td>
                 <td>  </td>
                  <td>  <?php echo $client['raison_social']; ?> </td>
                   <td>  </td>
				   <td><a href=detail-client.php?clientde=<?php echo $client['code_client_hto']?> class="btn btn-mini btn-primary" > Modification</a></td>
				   <td></td>
				   <td><a href=liste-client.php?supp=<?php echo $client['code_client_hto']?> class="btn btn-mini btn-danger">Suppression</a></td>
				   <td></td>
                   
                   
                   
                </tr>
				<?php }
?>
					</tr>
				  </tbody>
				</table>
    
    
 
    
    </fieldset>
 </div></div> <!-- /container -->

 
<?php require "includes/footer.php";?> 
 
        </body>
</html>

<?php }  }?>